From 76c07a95acd8b8ce87ac4846c0c096d65fd7c80b Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 13 Sep 2002 23:25:30 +0000 Subject: [PATCH] Be more consistent with formatting of internal erros. --- gpsbabel/csv.c | 8 +++++--- gpsbabel/gpsman.c | 8 +++++--- gpsbabel/gpsutil.c | 8 +++++--- gpsbabel/gpx.c | 12 +++++++----- gpsbabel/magproto.c | 21 +++++++++++---------- gpsbabel/mapsource.c | 6 ++++-- gpsbabel/pcx.c | 7 +++++-- gpsbabel/psp.c | 16 +++++++++------- gpsbabel/tiger.c | 8 +++++--- 9 files changed, 56 insertions(+), 38 deletions(-) diff --git a/gpsbabel/csv.c b/gpsbabel/csv.c index abfef221b..c2cd9c4f9 100644 --- a/gpsbabel/csv.c +++ b/gpsbabel/csv.c @@ -26,12 +26,14 @@ static FILE *file_in; static FILE *file_out; +#define MYNAME "CSV" + static void rd_init(const char *fname) { file_in = fopen(fname, "r"); if (file_in == NULL) { - fatal("GPSUTIL: Cannot open %s for reading\n", fname); + fatal(MYNAME ": Cannot open %s for reading\n", fname); } } @@ -46,7 +48,7 @@ wr_init(const char *fname) { file_out = fopen(fname, "w"); if (file_out == NULL) { - fatal("GPSUTIL: Cannot open %s for writing\n", fname); + fatal(MYNAME ": Cannot open %s for writing\n", fname); } } @@ -68,7 +70,7 @@ data_read(void) &lat, &lon, desc) > 0) { wpt_tmp = calloc(sizeof(*wpt_tmp),1); if (wpt_tmp == NULL) { - fatal("GPSMAN: cannot allocate memory\n"); + fatal(MYNAME ": cannot allocate memory\n"); } while (*odesc == ' ' || *odesc == '\t') { odesc++; diff --git a/gpsbabel/gpsman.c b/gpsbabel/gpsman.c index e115e7d82..c67f0af6d 100644 --- a/gpsbabel/gpsman.c +++ b/gpsbabel/gpsman.c @@ -22,12 +22,14 @@ static FILE *in_file; static FILE *out_file; +#define MYNAME "GPSMAN" + static void gpsman_rd_init(const char *fname) { in_file = fopen(fname, "r"); if (in_file == NULL) { - fatal("GPSMAN: Cannot open %s for reading\n", fname); + fatal(MYNAME ": Cannot open %s for reading\n", fname); } } @@ -42,7 +44,7 @@ gpsman_wr_init(const char *fname) { out_file = fopen(fname, "w"); if (out_file == NULL) { - fatal("GPSMAN: Cannot open %s for writing\n", fname); + fatal(MYNAME ": Cannot open %s for writing\n", fname); } fprintf(out_file, "!Format: DDD 1 WGS 84\n"); @@ -97,7 +99,7 @@ gpsman_read(void) wpt_tmp = calloc(sizeof(*wpt_tmp),1); if (wpt_tmp == NULL) { - fatal("GPSMAN: Cannot allocate enough memory\n"); + fatal(MYNAME ": Cannot allocate enough memory\n"); } lat = latm + latf; diff --git a/gpsbabel/gpsutil.c b/gpsbabel/gpsutil.c index 1b046a128..550d83113 100644 --- a/gpsbabel/gpsutil.c +++ b/gpsbabel/gpsutil.c @@ -8,12 +8,14 @@ static FILE *file_in; static FILE *file_out; +#define MYNAME "GPSUTIL" + static void rd_init(const char *fname) { file_in = fopen(fname, "r"); if (file_in == NULL) { - fatal("GPSUTIL: Cannot open %s for reading\n", fname); + fatal(MYNAME ": Cannot open %s for reading\n", fname); } } @@ -28,7 +30,7 @@ wr_init(const char *fname) { file_out = fopen(fname, "w"); if (file_out == NULL) { - fatal("GPSUTIL: Cannot open %s for writing\n", fname); + fatal(MYNAME ": Cannot open %s for writing\n", fname); } } @@ -55,7 +57,7 @@ data_read(void) &alt, &alttype, desc, icon) > 0) { wpt_tmp = calloc(sizeof(*wpt_tmp),1); if (wpt_tmp == NULL) { - fatal("GPSMAN: cannot allocate memory\n"); + fatal(MYNAME ": cannot allocate memory\n"); } wpt_tmp->position.altitude.altitude_meters = alt; wpt_tmp->shortname = strdup(name); diff --git a/gpsbabel/gpx.c b/gpsbabel/gpx.c index 58b84fefe..2c681ccaa 100644 --- a/gpsbabel/gpx.c +++ b/gpsbabel/gpx.c @@ -38,6 +38,8 @@ static waypoint *wpt_tmp; static FILE *fd; static FILE *ofd; +#define MYNAME "GPX" + static void tag_gpx(const char **attrv) { @@ -60,7 +62,7 @@ tag_wpt(const char **attrv) wpt_tmp = calloc(sizeof(*wpt_tmp), 1); if (wpt_tmp == NULL) { - fatal("Can not allocate memory\n"); + fatal(MYNAME ": allocate memory\n"); } while (*avp) { @@ -157,11 +159,11 @@ gpx_rd_init(const char *fname) { fd = fopen(fname, "r"); if (fd == NULL) { - fatal("GPX: Cannot open %s for reading\n", fname ); + fatal(MYNAME ": Cannot open %s for reading\n", fname ); } psr = XML_ParserCreate(NULL); if (!psr) { - fatal("GPX: Cannot create XML Parser\n"); + fatal(MYNAME ": Cannot create XML Parser\n"); } XML_SetElementHandler(psr, gpx_start, gpx_end); XML_SetCharacterDataHandler(psr, gpx_cdata); @@ -178,7 +180,7 @@ gpx_wr_init(const char *fname) { ofd = fopen(fname, "w"); if (ofd == NULL) { - fatal("GPX: Cannot open %s for writing\n", fname ); + fatal(MYNAME ": open %s for writing\n", fname ); } } @@ -198,7 +200,7 @@ gpx_read(void) len = fread(buf, 1, sizeof(buf), fd); done = feof(fd); if (!XML_Parse(psr, buf, len, done)) { - fatal("GPX: XML parse error at %d: %s\n", + fatal(MYNAME ": XML parse error at %d: %s\n", XML_GetCurrentLineNumber(psr), XML_ErrorString(XML_GetErrorCode(psr))); } diff --git a/gpsbabel/magproto.c b/gpsbabel/magproto.c index a60a7a9bf..c84c0197f 100644 --- a/gpsbabel/magproto.c +++ b/gpsbabel/magproto.c @@ -28,6 +28,7 @@ #include "magellan.h" #define BAUDRATE B4800 +#define MYNAME "MAGPROTO" #if __WIN32__ #include @@ -248,7 +249,7 @@ mag_verparse(char *ibuf) icon_mapping = map330_icon_table; break; default: - fatal("Magproto: Unknown receiver type.\n"); + fatal(MYNAME ": Unknown receiver type.\n"); } } @@ -267,7 +268,7 @@ mag_readmsg(void) if (!gr) { if (!got_version) { - fatal("Magproto: No data received from GPS.\n"); + fatal(MYNAME ": No data received from GPS.\n"); } else { if (is_file) { found_done = 1; @@ -293,7 +294,7 @@ if (debug_serial) fprintf(stderr, "RXERR %02x/%02x: '%s'\n", isum, mag_pchecksum(&ibuf[1],isz-5), ibuf); /* Special case receive errors early on. */ if (!got_version) { - fatal("Magproto: bad communication. Check bit rate.\n"); + fatal(MYNAME ": bad communication. Check bit rate.\n"); } } if (debug_serial) { @@ -343,7 +344,7 @@ terminit(const char *portname) OPEN_EXISTING, 0, NULL); if (comport == INVALID_HANDLE_VALUE) { - fatal("Cannot open '%s'", portname); + fatal(MYNAME ": '%s'", portname); } tio.DCBlength = sizeof(DCB); GetCommState (comport, &tio); @@ -367,7 +368,7 @@ terminit(const char *portname) if (!SetCommState (comport, &tio)) { CloseHandle(comport); - fatal("Unable to set port settings"); + fatal(MYNAME ": set port settings"); } GetCommTimeouts (comport, &timeout); @@ -376,7 +377,7 @@ terminit(const char *portname) timeout.WriteTotalTimeoutConstant = 1000; if (!SetCommTimeouts (comport, &timeout)) { CloseHandle (comport); - fatal("Unable to set timeouts"); + fatal(MYNAME ": set timeouts"); } } @@ -412,7 +413,7 @@ termwrite(char *obuf, int size) WriteFile (comport, obuf, size, &len, NULL); if (len != size) { - fatal("Write error. Wrote %d of %d bytes.", len, size); + fatal(MYNAME ":. Wrote %d of %d bytes.", len, size); } } @@ -437,7 +438,7 @@ terminit(const char *portname) magfile_in = fopen(portname, "rb"); if (magfile_in == NULL) { - fatal("Magproto: Cannot open %s.%s\n", + fatal(MYNAME ": Cannot open %s.%s\n", portname, strerror(errno)); } @@ -505,7 +506,7 @@ mag_rd_init(const char *portname) while (!got_version) { mag_readmsg(); if (time(NULL) > later) { - fatal("Magproto: No acknowledgment from GPS on %s\n", + fatal(MYNAME ": No acknowledgment from GPS on %s\n", portname); } } @@ -677,7 +678,7 @@ mag_wptparse(char *trkmsg) waypt = calloc(sizeof *waypt, 1); if (waypt == NULL) - fatal("Magproto: Cannot allocate memory\n"); + fatal(MYNAME ": Cannot allocate memory\n"); sscanf(trkmsg,"$PMGNWPL,%lf,%c,%lf,%c,%d,%c,%[^,],%[^,]", &latdeg,&latdir, diff --git a/gpsbabel/mapsource.c b/gpsbabel/mapsource.c index a1e7e7621..da715d287 100644 --- a/gpsbabel/mapsource.c +++ b/gpsbabel/mapsource.c @@ -27,12 +27,14 @@ static FILE *mapsource_file_in; static FILE *mapsource_file_out; +#define MYNAME "MAPSOURCE" + static void mapsource_rd_init(const char *fname) { mapsource_file_in = fopen(fname, "r"); if (mapsource_file_in == NULL) { - fatal("Cannot open '%s' for reading\n", fname); + fatal(MYNAME ": '%s' for reading\n", fname); } } @@ -47,7 +49,7 @@ mapsource_wr_init(const char *fname) { mapsource_file_out = fopen(fname, "w"); if (mapsource_file_out == NULL) { - fatal("Cannot open '%s' for writing\n", fname); + fatal(MYNAME ": '%s' for writing\n", fname); exit(1); } } diff --git a/gpsbabel/pcx.c b/gpsbabel/pcx.c index 4cffcc017..dfd45aa0a 100644 --- a/gpsbabel/pcx.c +++ b/gpsbabel/pcx.c @@ -25,12 +25,15 @@ static FILE *file_in; static FILE *file_out; +#define MYNAME "PCX" + + static void rd_init(const char *fname) { file_in = fopen(fname, "r"); if (file_in == NULL) { - fatal("GPSUTIL: Cannot open %s for reading\n", fname); + fatal(MYNAME ": Cannot open %s for reading\n", fname); } } @@ -45,7 +48,7 @@ wr_init(const char *fname) { file_out = fopen(fname, "w"); if (file_out == NULL) { - fatal("GPSUTIL: Cannot open %s for writing\n", fname); + fatal(MYNAME ": Cannot open %s for writing\n", fname); } } diff --git a/gpsbabel/psp.c b/gpsbabel/psp.c index 19e8533f7..c8a8f38fe 100644 --- a/gpsbabel/psp.c +++ b/gpsbabel/psp.c @@ -25,6 +25,8 @@ #include #include /* for M_PI */ +#define MYNAME "PSP" + /*#define _DEBUG_PSP 1*/ #define MAXPSPSTRINGSIZE 256 #define MAXPSPOUTPUTPINS 8192 /* Any more points than this is ludicrous */ @@ -68,7 +70,7 @@ psp_rd_init(const char *fname) { psp_file_in = fopen(fname, "r"); if (psp_file_in == NULL) { - fatal("PSP: Cannot open %s for reading\n", fname); + fatal(MYNAME ": Cannot open %s for reading\n", fname); } } @@ -83,7 +85,7 @@ psp_wr_init(const char *fname) { psp_file_out = fopen(fname, "w"); if (psp_file_out == NULL) { - fatal("PSP: Cannot open %s for writing\n", fname); + fatal(MYNAME ": Cannot open %s for writing\n", fname); } } @@ -111,7 +113,7 @@ psp_read(void) wpt_tmp = calloc(sizeof(*wpt_tmp),1); if (wpt_tmp == NULL) { - fatal("PSP: cannot allocate memory\n"); + fatal(MYNAME ": cannot allocate memory\n"); } /* things we will probably never know about this waypoint */ @@ -163,7 +165,7 @@ psp_read(void) stringsize *= 2; if (stringsize > MAXPSPSTRINGSIZE) { - fatal("PSP: variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE); + fatal(MYNAME ": variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE); } /* stringsize bytes - string data */ @@ -184,7 +186,7 @@ psp_read(void) stringsize *= 2; if (stringsize > MAXPSPSTRINGSIZE) { - fatal("PSP: variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE); + fatal(MYNAME ": variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE); } #ifdef _DEBUG_PSP @@ -208,7 +210,7 @@ psp_read(void) stringsize *= 2; if (stringsize > MAXPSPSTRINGSIZE) { - fatal("PSP: variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE); + fatal(MYNAME ": variable string size (%d) in PSP file exceeds MAX (%d).\n", stringsize, MAXPSPSTRINGSIZE); } @@ -318,7 +320,7 @@ psp_write(void) s = waypt_count(); if (s > MAXPSPOUTPUTPINS) { - fatal("attempt to output too many pushpins (%d). The max is %d. Sorry.\n", s, MAXPSPOUTPUTPINS); + fatal(MYNAME ": output too many pushpins (%d). The max is %d. Sorry.\n", s, MAXPSPOUTPUTPINS); } /* insert waypoint count into header */ diff --git a/gpsbabel/tiger.c b/gpsbabel/tiger.c index da611fc26..5978153eb 100644 --- a/gpsbabel/tiger.c +++ b/gpsbabel/tiger.c @@ -25,12 +25,14 @@ static FILE *file_in; static FILE *file_out; +#define MYNAME "GPSUTIL" + static void rd_init(const char *fname) { file_in = fopen(fname, "r"); if (file_in == NULL) { - fatal("GPSUTIL: Cannot open %s for reading\n", fname); + fatal(MYNAME ": Cannot open %s for reading\n", fname); } } @@ -45,7 +47,7 @@ wr_init(const char *fname) { file_out = fopen(fname, "w"); if (file_out == NULL) { - fatal("GPSUTIL: Cannot open %s for writing\n", fname); + fatal(MYNAME ": Cannot open %s for writing\n", fname); } } @@ -73,7 +75,7 @@ abort(); &alt, &alttype, desc, icon) > 0) { wpt_tmp = calloc(sizeof(*wpt_tmp),1); if (wpt_tmp == NULL) { - fatal("GPSMAN: cannot allocate memory\n"); + fatal(MYNAME ": cannot allocate memory\n"); } wpt_tmp->position.altitude.altitude_meters = alt; wpt_tmp->shortname = strdup(name); -- 2.30.2